(function($){
    /*模板引擎设置*/
    _.templateSettings = {
        interpolate: /\{\{(.+?)\}\}/g
    };


    $.log=function(content,title,format){
        if (typeof content == 'object') {
            content = JSON.stringify(content, null, '\t');
            if (format) {
                content = content.replace(/\n/g, '<br/>').replace(/\t/g, ' &nbsp; &nbsp; ');
            }
            if(arguments.length>3){
                var keywords = Array.prototype.slice.call(arguments, 3);
                for(var i=0;i<keywords.length;i++){
                    var keyword = keywords[i];
                    content=content.replace(new RegExp('"'+keyword+'"',"g"),'<span style="background:yellow">"'+keyword+'"</span>');
                }
            }
        }

        // 为消息增加点击事件，开始时折叠消息
        var $msg = $('<p/>').addClass('shortMsg').click(function() {
            $(this).toggleClass('shortMsg');
        });


        var _title=title||">>";
        $('<span/>').css('color', 'red').text(_title + ' ').appendTo($msg);
        $('<span/>').html(content).appendTo($msg);
        $msg.appendTo('#debugInfo > div');
    };

    $("#reloadPage").on("click",function(){
        location.reload();
    });

})(Zepto);

(function($){
    $(document).ready(function () {
        var Student=Backbone.Model.extend({
            initialize:function(){
               this.on("invalid",function(model,error){
                   console.log(error);
               });

               this.on("change:Name",function(model,value){
                   console.log("you trigger Name sty");
               });
            },

            validate:function(attrs){
                if(!_.isString(attrs.Name)){
                    return "not string!!";
                }

                if(!_.isNumber(attrs.Score)){
                    return "not number!!";
                }
            },

            defaults:{
                Code:"",
                Name:"wong",
                Score:""
            }

        });

        var stuA=new Student();
        stuA.set({
            Code:"10105",
            Name:"jian",
            Score:123456
        },{"validate":true});

        $.log(stuA.toJSON());


    });
})(Zepto);